package com.qf.contract.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.common.base.exception.ServiceException;
import com.qf.common.base.result.ResultCode;
import com.qf.contract.entity.FAddressBook;
import com.qf.contract.mapper.FAddressBookMapper;
import com.qf.contract.service.FAddressBookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class FAddressBookServiceImpl implements FAddressBookService {
    @Resource
    FAddressBookMapper fAddressBookMapper;

    @Override
    public int addFAddressBookService(FAddressBook fAddressBook) {
        return fAddressBookMapper.insert(fAddressBook);
    }

    @Override
    public int delFAddressBookService(int id) {
        return fAddressBookMapper.deleteById(id);

    }

    @Override
    public int upFAddressBookService(FAddressBook fAddressBook) {
        return fAddressBookMapper.updateById(fAddressBook);
    }

    @Override
    public Page<FAddressBook> selectFAddressBookService(int current, int size) {
        try {
            Page<FAddressBook> fChangeRequestPage = fAddressBookMapper.selectPage(new Page<>(current, size), null);
            return fChangeRequestPage;
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }
}
